<template>
  <div>
    <el-table :data="userData" stripe>
      <el-table-column prop="nickname" label="名称"></el-table-column>
      <el-table-column prop="avatarUrl" label="图片">
        <template v-slot="scope">
          <el-image :src="scope.row.avatarUrl" style="width:50px;height:50px;"></el-image>
        </template>
      </el-table-column>
      <el-table-column prop="phone" label="手机号"></el-table-column>
      <el-table-column prop="gmtCreate" label="创建时间"></el-table-column>
      <el-table-column prop="gmtModify" label="修改时间"></el-table-column>
      <el-table-column prop label="操作">
        <template v-slot="scope">
          <el-button type="primary">编辑</el-button>
          <el-button type="danger" @click="delStore(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination background layout="prev, pager, next" :total="100"></el-pagination>
  </div>
</template>
<script>
export default {
  inject: ["reload"],
  data: function() {
    return {
      userData: []
    };
  },
  async created() {
    const { data } = await this.$http.get(
      `/sysUser/listPage?pageNum=1&pageSize=10`
    );
    this.userData.push(...data.data.modelList);
  },
  methods: {
    delStore: async function(id) {
      const { data } = await this.$http.post(`/cwUser/delete`, { id });
      if (data.success) {
        this.$message({
          message: '删除成功',
          type: 'success'
        });
        this.reload();
      }
    }
  }
};
</script>
<style scoped>
</style>